package day3;

import java.util.Scanner;

import org.junit.Test;

public class Demo {
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入学生的数量：");
		int count = scanner.nextInt();
		Student[] students = new Student[count];
		
		for (int i = 0; i < students.length; i++) {
			
			System.out.println("请输入id");
			int id = scanner.nextInt();
			System.out.println("请输入姓名");
			String name = scanner.next();
			System.out.println("请输入年龄");
			int age = scanner.nextInt();
			System.out.println("请输入班级");
			String className = scanner.next();
			
			//每次循环构造一个Student对象
			Student student = new Student();
			student.id = id;
			student.name = name;
			student.className = className;
			student.age = age;
			//把构造的学生对象放到指定下标位置
			students[i] = student;
		}
		for (int i = 0; i < students.length; i++) {
			Student student = students[i];
			System.out.println("学生的是学号是"+student.id);
			System.out.println("学生的是姓名是"+student.name);
			System.out.println("学生的是年龄是"+student.age);
			System.out.println("学生的班级名称是"+student.className);
			System.out.println("------------------------------");
		}
		
	}
	
	
	//面向对象实例
	@Test
	public void test1() {
		int num = 3;
		
		//new出一个Student对象
		Student zhangsan = new Student();
		
		zhangsan.id = 1;
		zhangsan.name = "张三";
		zhangsan.className = "JAVA1912";
		zhangsan.age = 23;
		
		zhangsan.study();

		Student lisi = new Student();
		
		lisi.id = 2;
		lisi.name = "李四";
		lisi.className = "UI1912";
		lisi.age = 20;
		lisi.study();
	}
}
